﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>点餐后台管理系统</title>
   <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/default/easyui.css"></link>

<link  rel="stylesheet" href="css/style.css" type="text/css" />
<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script>
<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.easyui.min.js"></script>

<script type="text/javascript">
  $(document).ready(  
		  function(){
			  $('#login_id').focus();
		  });
  
  function submitForm(){
		
		var userid = $("#login_id").val();
		var pwd = $("#login_pwd").val();
		
		if(userid.length==0)
		{
			alert("请输入用户名");
			return ;
		}
		
		if(pwd.length==0)
		{
			alert("请输入密码");
			return ;
		}
		
		$.post("user_login",
				$('#ff').serialize(),
				  function(data){
				
			       var ret = data.split('|');
			       
				    if(ret[0]=="success")
				    {
				    	window.location.href="/login_success?key="+ret[1];
				    }else
				    {
				    	alert("用户名或密码错");
				    }
				  },
				  "text");//这里返回的类型有：json,html,xml,text
	}
	function clearForm(){
		$('#ff').form('clear');
	}
	
	function openDailog()
	{
		
		$('#resetdlg').dialog('open');
		$('#userid').focus();
	}
	
function submitForm1(){
		
		var userid = $("#userid").val();
		var orpwd = $("#orpwd").val();
		var nepwd = $("#nepwd").val();
		
		if(userid.length==0)
		{
			alert("请输入用户名");
			return ;
		}
		if(orpwd.length==0)
		{
			alert("请输入旧密码");
			return ;
		}
		if(nepwd.length==0)
		{
			alert("请输入新密码");
			return ;
		}
		
		
		$.post("updatePwd",
				$('#ff1').serialize(),
				  function(data){
				    if(data=="success")
				    {
				    	alert("修改成功！");
				    	$('#resetdlg').dialog('close');
				    	 $('#login_id').focus();
				    }else
				    {
				    	alert("旧密码有误！");
				    	$('#orpwd').val("");
				    	$('#orpwd').focus(); 
				    }
				  },
				  "text");//这里返回的类型有：json,html,xml,text
	}
	function clearForm1(){
		$('#ff1').form('clear');
	}
	
	function id_enter()
	 {     
	       if (event.keyCode == 13) 
	       {      
	    	   $('#login_pwd').focus();
	       }
	 }
	
	function userid_enter()
	 {     
	       if (event.keyCode == 13) 
	       {      
	    	   $('#orpwd').focus();
	       }
	 }
	function orpwd_enter()
	 {     
	       if (event.keyCode == 13) 
	       {      
	    	   $('#nepwd').focus();
	       }
	 }
	
	function nepwd_enter()
	 {     
	       if (event.keyCode == 13) 
	       {      
	    	   submitForm1();
	       }
	 }
	
	function pwd_enter()
	 {     
	       if (event.keyCode == 13) 
	       {      
	    	   submitForm();
	       }
	 }
	
 </script>

</head>

<body >
<form id="ff"  style="margin:0px">
<div id="box">
		
<div id="block">
                		<div id="userLogin"></div>
                        <div id="login">
                        		<div id="left"><img src="images/yaoshi.png" width="115" height="128"/></div>
                        		<div id="right">
                                 <div class="field ph-hide">
            <label for="TPL_username_1">用户名：</label>
            <input type="text" name="login_id" id="login_id" onkeypress="id_enter()"  class="login-text J_UserName" value="" maxlength="32" tabindex="1"/>            	
        </div>
			<div class="field">
			  <label id="password-label">密　码：</label>
			  <input type="password" name="login_pwd" id="login_pwd" onkeypress="pwd_enter()" class="login-text J_UserName" value="" maxlength="32" tabindex="1"/>
			</div>
                        </div>
                </div>
        <div id="bottom"> <button type="button" onclick="submitForm()" class="J_Submit" tabindex="5">登&nbsp;录</button>&nbsp;&nbsp;&nbsp;<a href="#" onclick="openDailog()">修改密码？</a></div>
        </div>

</div>
</form>
<div id="resetdlg" class="easyui-dialog" title="修改密码"  data-options="iconCls:'icon-save',modal:true,closed:true" style="width:400pxpx;height:400pxpx">
		<center>
       	 <form id="ff1">
       	    <table>
       	    	<tr>
       	    		<td>用户名：</td>
       	    		<td><input type="text"  name="userid" id="userid"  onkeypress="userid_enter()" style="width:120px"/></td>
       	    	</tr>
       	    	<tr>
       	    		<td>旧密码：</td>
       	    		<td><input type="password"  name="orpwd" id="orpwd" onkeypress="orpwd_enter()" style="width:120px"/></td>
       	    	</tr>
       	    	<tr>
       	    		<td>新密码：</td>
       	    		<td><input type="password" name="nepwd" id="nepwd" onkeypress="nepwd_enter()" style="width:120px"/></td>
       	    	</tr>
       	    	
       	    </table>
        	<a href="#" class="easyui-linkbutton" onclick="submitForm1()">提&nbsp;&nbsp;交</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="easyui-linkbutton" onclick="clearForm1()">重&nbsp;&nbsp;置</a>
         </form>
         </center>
	</div>

</body>
</html>
